/**
 * 问题进度
 * Created by wenchuan.li on 2018/6/14 11:16.
 */
define(function () {

    var self,
        app = win.app,
        orderSubmitArg,
        searchData = {
            keyword: '',
            GWAKL004: '',
            ESAASTUS: '',
            ESAA004_START: '',
            ESAA004_END: '',
            ESAA008: '',
            ESAA002: ''
        }
    ;
    var mask = mui.createMask();

    var Customers = app.newModule({

        init: function () {
            self = this;
            self._super({
                _tag: 'p_wtjd',
                _refreshAutoInit: true, //自动加载刷新控件
                _search: {
                    methods: {
                        choose: function () {
                            $(".modal1").css("display", "block");
                            mask.show();
                        }
                    }
                }
            }, win);
            //orderSubmitArg = app.pageParameters['customers'];
        },
        _initRefresh: function () { // 实例化刷新组件
            if (self._refreshIds.length == 0) {
                self._refreshIds = ['scroll1'];
            }
            this._super(win);
        },
        _refreshCb: function (goods) {// 刷新组件回调函授
            var _super = this._super;
            app.ajax({
                xurl: "api/wtjd/getEsaaList",
                xdata: {
                    page: goods.page + 1,
                    limit: goods.limit,
                    keyword: searchData.keyword,
                    ESAA002: searchData.ESAA002,
                    ESAA008: searchData.ESAA008,
                    ESAA004_START: searchData.ESAA004_START,
                    ESAA004_END: searchData.ESAA004_END,
                    ESAASTUS: searchData.ESAASTUS,
                    GWAKL004: searchData.GWAKL004
                },
                cb: function (result) {
                    if (result.ok) {
                        //goods.data.length = 0;
                        var data = result.data;
                        goods.data.pushArray(data.data, goods.page == 0);

                        _super({
                            obj: goods,
                            dataLen: data.data.length,
                            nodata: '无客户信息...'
                        });
                    }
                }
            });
        },
        _search: function (data) {
            searchData.keyword = data.keyword.trim();
            self._refresh();
        },
        _lazy: function () {
            this._super();

            // console.log(vue2)
        },
        _ready: function () {
            Vue.component('wtjditem', {
                template: app.getByid(doc, 'wtjditem-template'),
                props: {
                    model: Array
                },
                methods: {
                    select: function (v) {
                        orderSubmitArg.cb(v);
                        app.back(1);
                    }
                }
            });
            var vue2 = new Vue({
                el: doc.querySelector('.modal1'),
                data: searchData,
                methods: {
                    search: function () {
                        self._refresh();
                        $(".modal1").css("display", "none");
                        mask.close();
                    },
                    cancle: function () {
                        $(".modal1").css("display", "none");
                        mask.close();
                    }
                }
            });

        }
    });

});